package com.gdx.game.screen.base;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.gdx.game.MyGame;
import com.gdx.game.resource.ResourceManager;


public class MenuScreen extends BaseScreen {

    public MenuScreen(final MyGame game, final ResourceManager rm) {
        super(game, rm);

        ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle();
        style.imageUp = new TextureRegionDrawable(rm.icoClose20x20);
        style.imageDown = new TextureRegionDrawable(rm.icoClose20x20);
        ImageButton exitButton = new ImageButton(style);
        exitButton.setSize(18, 18);
        exitButton.setPosition(177, 99);

        exitButton.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                setFadeScreen(game.menuScreen);
            }
        });

        stage.addActor(exitButton);
    }


    @Override
    public void show() {
        super.show();
        stage.addAction(Actions.alpha(1.0f));
    }

    @Override
    public void render(float delta) {
        //清屏
        Gdx.gl.glClear( GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT );
        if(renderBatch.get()) {
            stage.getBatch().begin();
            stage.getBatch().end();
        }
        super.render(delta);
    }
}
